package core;

import java.util.ArrayList;
import java.util.List;

import main.SYRRES;

public class SetBeer {
	List<Beer> listBeer;
	private int[] sumNote = new int[SYRRES.NB_NOTE];
	
	public SetBeer() {
		listBeer = new ArrayList<Beer>();
	}
	
	public int hasBeer(String id) {
		for (int i = 0; i < listBeer.size(); i++) {
			if (id.equals(listBeer.get(i).getId())) {
				return i;
			}
		}
		return -1;
	}
	
	public int size() {
		return listBeer.size();
	}
	
	public void addBeer(String id) {
		listBeer.add(new Beer(id));
	}
	
	public Beer getLastBeer() {
		return listBeer.get(listBeer.size() - 1);
	}
	
	public Beer getBeer(int pos) {
		return listBeer.get(pos);
	}
	
	public void clearUsers() {
		for (Beer b : listBeer) {
			b.clearUser();
		}
	}
	
	public void calculSumNote(int noteID) {
		int sum = 0;
		for (Beer beer : listBeer) {
			beer.calculSumNote(noteID);
			sum += beer.getSumNote(noteID);
		}
		sumNote[noteID] = sum;
	}
	
	public int getSumNote(int noteID) {
		return sumNote[noteID];
	}
}
